﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using JustinAngel.Neurons.Services;
using Microsoft.Phone.Controls;
using JustinAngel.Neurons.Framework.Helpers;

namespace JustinAngel.Neurons.Pages.Splash
{
    public partial class SplashPage : PhoneApplicationPage
    {
        public SplashPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var videoViewModel = new ZuneMediaHubIntegrationService().LoadHistoryOrNowPlayingTileClick(NavigationContext);
            if (videoViewModel != null)
            {
                this.DataContext.As<SplashViewModel>().ZuneTileClickOnVideoItem = videoViewModel;
            }
            this.DataContext.As<SplashViewModel>().OnNavigatedTo();
        }

        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            mediaElement.Pause();
        }
    }
}